home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TGCBOR20.ARJ / INTROPAK.COM / TSTPICK1.C < prev    next >
C/C++ Source or Header  |  1991-04-07  |  3KB  |  95 lines

  1. /* shows the use of drop down pick list. */
  2.  
  3. #include "teglsys.h"
  4.  
  5. char pickeditem[255];
  6.  
  7. unsigned exitoption(imagestkptr fs,msclickptr ms)
  8. {
  9.     abortexit(pickeditem);
  10.     return 1;
  11. }
  12.  
  13. unsigned droppicklist(imagestkptr fs,unsigned userkey,void *dataarea)
  14. {
  15.     optionmptr picklist = (optionmptr) dataarea;
  16.  
  17.     dropoptionmenu(picklist);
  18.     return 0;
  19. }
  20.  
  21. unsigned gotitem(imagestkptr fs,msclickptr ms)
  22. {
  23.     beep(500,4,50);
  24.     return 1;
  25. }
  26.  
  27.  
  28. void createtestpicklist(void)
  29. {
  30.     unsigned x,y,x1,y1;
  31.     unsigned ax,ay,ax1,ay1;
  32.     optionmptr picklist;
  33.     imagestkptr ifs;
  34.     unsigned margins;
  35.     unsigned maxwidth;
  36.  
  37.     x = 100;
  38.     y = 100;
  39.     x1 = x+200;
  40.     y1 = y+200;
  41.     margins = 2;
  42.     maxwidth = 150;
  43.  
  44.     pushimage(x,y,x1,y1);
  45.     shadowbox(x,y,x1,y1);
  46.  
  47.     /*---------------------------------------------------------------------*/
  48.     /* Create an edit event to allow the user to edit the selected item    */
  49.     /*---------------------------------------------------------------------*/
  50.     ax = 10+2+margins;        /* <-- pick list adds 2 pixel before the text */
  51.     ay = 10+2;
  52.     ax1 = ax+maxwidth;
  53.     ay1 = ay+14;          /* <-- Font height */
  54.  
  55.     setkeyboardmouse(FALSE);
  56.     ifs = stackptr;
  57.     definestreditevent(ifs,ax,ay,ax1,ay1,40,BLUE,font14,TRUE,pickeditem,allchars,strredisplay,strredisplay,NULL);
  58.     addmouseclickmask(getlastmsptr(ifs),(maskptr)maskcursor,2,6);
  59.  
  60.  
  61.     /*---------------------------------------------------------------------*/
  62.     /* Create drop down pick list event                    */
  63.     /*---------------------------------------------------------------------*/
  64.     picklist = createpicklist(font14);
  65.     setpicklistmargin(picklist,margins);
  66.     setpicklistwidth(picklist,maxwidth);
  67.     definepickitem(picklist,"item one on list",gotitem,pickeditem);
  68.     definepickitem(picklist,"item two on list",gotitem,pickeditem);
  69.     definepickitem(picklist,"item three on list",gotitem,pickeditem);
  70.     definepickitem(picklist,"item four on list",gotitem,pickeditem);
  71.     definepickitem(picklist,"item five on list",gotitem,pickeditem);
  72.     definepickitem(picklist,"item three on list",gotitem,pickeditem);
  73.     definepickitem(picklist,"item six on list",gotitem,pickeditem);
  74.     definepickitem(picklist,"item seven on list",gotitem,pickeditem);
  75.  
  76.     definepicklistarea(ifs,10,10,3,1,picklist);
  77.  
  78.     /*---------------------------------------------------------------------*/
  79.     /* define a user data area for the picklist with an arbitrary       */
  80.     /* key of 222.                               */
  81.     /*---------------------------------------------------------------------*/
  82.     setuserdataarea(ifs,222,picklist,droppicklist);
  83. }
  84.  
  85.  
  86. void main()
  87. {
  88.     easytegl();
  89.     easyout();
  90.  
  91.     createtestpicklist();
  92.  
  93.     teglsupervisor();
  94. }
  95.